/**
 * 
 */
package com.google.code.rookery.converter;

import java.util.ArrayList;
import java.util.List;

/**
 * Test converter to convert a list of phones
 * @author Xerox
 */
public class PhoneConverter extends InstanceConverter{

  /* (non-Javadoc)
   * @see com.google.code.rookery.converter.InstanceConverter#convert(java.lang.Object)
   */
  @SuppressWarnings("unchecked")
  @Override
  public Object convert(Object obj) {
    List<String> phoneList = (List<String>) obj;
    List<Integer> result = new ArrayList<Integer>();
    for(String phone:phoneList){
      Integer val;
      if(phone==null||phone.length()==0){
        val = 0;
      }
      else{
        val = Integer.parseInt(phone);
      }
      result.add(val);
    }
    return result;
  }
}
